//index.js
//获取应用实例
const app = getApp()
const sm2 = require('miniprogram-sm-crypto').sm2;

Page({
  data: {
    count: 0,
    message: 'gp18',
    // cities:['北京','上海','天津'],
    cities: [{
      id: 0,
      name: "北京"
    }, {
      id: 1,
      name: "上海"
    }],
    view: 'APP',
    userInfo: {
      username: 'xiaoming',
      age: 20
    }
  },
  //事件处理函数
  bindViewTap: function () {
    wx.navigateTo({
      url: '../logs/logs'
    })
  },
  golog() {
    console.log('golog ...')
    wx.switchTab({
      url: '/pages/logs/logs',
    })
  },
  handleChange() {
    this.setData({
      message: "北京"
    })
  },

  handleTap(event) {
    console.log('handleTap', event)
    console.log(event.currentTarget.dataset.hi)
  },
  onLoad: function () {
    let keypair = sm2.generateKeyPairHex();
    let publicKey = keypair.publicKey; // 公钥
    let privateKey = keypair.privateKey; // 私钥
    console.log(publicKey,privateKey)

  },
  getUserInfo: function (e) {
    // console.log(e)
    // app.globalData.userInfo = e.detail.userInfo
    // this.setData({
    //   userInfo: e.detail.userInfo,
    //   hasUserInfo: true
    // })
  },
  handleTap1() {
    console.log('handle tap1')
  },
  handleTap2() {
    console.log('handle tap2')
  },
  handleTap3() {
    console.log('handle tap3')
  },
  handleTap4() {
    console.log('handle tap4')
  },

  increment(event) {
    console.log('index page increment')
    console.log(event)
    this.setData({
      count: event.detail
    })
  }
})